package com.ren.market.service;


import com.ren.bean.TiceketDto;
import com.ren.market.bean.Ticket;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class MovieService {
    @Autowired
    ITicketService ticketService;
    @Autowired
    IMovieService movieService;
    @Scheduled(cron = "0 14 15 * * ?")
    public void remoteMovie(){
          List<TiceketDto> ticket = movieService.findTicket();
          List<Ticket> tickets=new ArrayList<>();
          for (TiceketDto t:
                  ticket) {
              Ticket ticeket1=new Ticket();
              BeanUtils.copyProperties(t,ticeket1);
              tickets.add(ticeket1);
          }
          boolean b = ticketService.saveBatch(tickets);
    }
}
